import { ref } from 'vue'

import { catchFn } from '@/libs/common'
import { getQuizResult } from '../../api'

/** 会话ID */
const sessionId = ref('')
/** 测评类型Code */
const typeCode = ref('')

/** 当前题目 */
const question = ref<T_Question>()
/** 手相面相测试结果 */
const result = ref<T_PhysiognomyResult>()

export { sessionId, typeCode, question, result }

/**
 * 更新测试结果
 */
const getResult = () =>
  catchFn(async () => {
    if (result.value) return

    const { data } = await getQuizResult({ typeCode: 'physiognomy' })

    result.value = data.physiognomyResult
  })

/**
 * 清空
 */
const clear = () => {}

export { getResult, clear }
